﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Dack_Web2.DTO;
using System.Data.OleDb;

namespace Dack_Web2.DAO
{
    public class CommentDAO
    {
        public void Insert(CommentDTO tmp)
        {
            
            string str = "insert into Comment(MaDeal, MaUser, ThoiGian, NoiDung) values (@MaDeal, @MaUser, @ThoiGian, @NoiDung)";
            
            OleDbParameter[] para1 ={ new OleDbParameter("@MaDeal", tmp.MaDeal),
                                      new OleDbParameter("@MaUser", tmp.MaUser),
                                      new OleDbParameter("@ThoiGian", tmp.ThoiGian),
                                      new OleDbParameter("@NoiDung", tmp.NoiDung)};
            Sql_DataProvider.SQL_ExecuteNonQuery(str, para1);
        }

        public void Update(CommentDTO tmp)
        {
           
            string str = "update Comment set MaDeal=@MaDeal, MaUser=@MaUser, ThoiGian=@ThoiGian, NoiDung=@NoiDung where MaComment=@MaComment";
            
            OleDbParameter[] para1 = {new OleDbParameter("@MaDeal", tmp.MaDeal),
                                      new OleDbParameter("@MaUser", tmp.MaUser),
                                      new OleDbParameter("@ThoiGian", tmp.ThoiGian),
                                      new OleDbParameter("@NoiDung", tmp.NoiDung),
                                      new OleDbParameter("@MaComment", tmp.MaComment)};
            Sql_DataProvider.SQL_ExecuteNonQuery(str, para1);
        }

        public void Delete(CommentDTO tmp)
        {
            
            string str = "delete from Comment where MaComment=@MaComment";

            OleDbParameter[] para1 = { new OleDbParameter("@MaComment", tmp.MaComment) };

            Sql_DataProvider.SQL_ExecuteNonQuery(str, para1);
        }
    }
}